package com.fmk.utils;

import java.io.File;
import java.util.Collection;

import org.apache.commons.io.filefilter.IOFileFilter;
import org.apache.commons.io.filefilter.TrueFileFilter;

public final class FileUtils {

    private FileUtils() {
    }

    /**
     * 
     * @param directory the directory to search in
     * @param fileFilter filter to apply when finding files.
     * @return an collection of java.io.File with the matching files
     */
    public static File[] listAllFiles(final File directory, final IOFileFilter fileFilter) {
        final IOFileFilter dirFilter = TrueFileFilter.INSTANCE;
        final Collection<File> listFiles = org.apache.commons.io.FileUtils.listFiles(directory, fileFilter, dirFilter);
        final File[] array = org.apache.commons.io.FileUtils.convertFileCollectionToFileArray(listFiles);
        return array;
    }
}